package com.lintcode.solution;

public class Solution_8 {
    public void rotateString(char[] str, int offset) {
        if (offset == 0 || (str == null || str.length == 0)) {
            return;
        }
        char temp1;
        int index = offset > str.length?offset % str.length:offset;
        for (int j = 1; j <= index; j++) {
            temp1 = str[ str.length - 1 ];
            for (int i = str.length - 1; i >= 1; i--) {
                str[ i ] = str[ i - 1 ];
            }
            str[ 0 ] = temp1;
        }
        System.out.println(new String(str));
    }

    public static void main(String[] args) {
        Solution_8 solution = new Solution_8();
        String str = "cppjavapy";
        solution.rotateString(str.toCharArray(), 25);
    }
}
